package treazy.ultimate.stats;

public class Game {
	private int _id;
	private Team team1;
	private Team team2;
	private int team1Points;
	private int team2Points;
	private Tournament tournament; // Change to string to save memory
	//ADD: game date
	
	// New game constructor
	public Game(Team t1, Team t2, Tournament tourney) {
		setTeam1(t1);
		setTeam2(t2);
		setTeam1Points(0);
		setTeam2Points(0);
		setTournament(tourney);
	}
	
	// Retrieved game constructor
	public Game(Team t1, Team t2, Tournament tourney, int t1Points, int t2Points) {
			setTeam1(t1);
			setTeam2(t2);
			setTeam1Points(t1Points);
			setTeam2Points(t2Points);
			setTournament(tourney);
	}
	
	public Team getTeam1() {
		return team1;
	}
	public void setTeam1(Team team1) {
		this.team1 = team1;
	}
	public Team getTeam2() {
		return team2;
	}
	public void setTeam2(Team team2) {
		this.team2 = team2;
	}
	public int getTeam1Points() {
		return team1Points;
	}
	public void setTeam1Points(int team1Points) {
		this.team1Points = team1Points;
	}
	public int getTeam2Points() {
		return team2Points;
	}
	public void setTeam2Points(int team2Points) {
		this.team2Points = team2Points;
	}
	public Team getWinner() {
		Team winner = null;
		
		//DB query to determine winner
		
		return winner;
	}
	public Tournament getTournament() {
		return tournament;
	}
	public void setTournament(Tournament tournament) {
		this.tournament = tournament;
	}
	
	public int score(Team team) {
		if(team.getName() == team1.getName()) {
			team1Points++;
			return team1Points;
		} else if (team.getName() == team2.getName()) {
			team2Points++;
			return team2Points;
		} else {
			return 0;
		}
	}
	
}
